import AlibabaCloudClientBaseConfig from './config';
// import Util, * as $Util from '@alicloud/tea-util';
// import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
// import OpenApiUtil from '@alicloud/openapi-util';
// import EndpointUtil from '@alicloud/endpoint-util';
// import * as $tea from '@alicloud/tea-typescript';

export class AlibabaCloudClient {
  private sdk;
  private init_config: InitConfigTypes;
  private params: object;
  private body;
  private method: string;
  private path: string;
  private headers: object;
  private client: any;
  constructor(params?: AlibabaCloudClientTypes) {
    // eslint-disable-next-line @typescript-eslint/no-var-requires
    this.sdk = require('@alicloud/bailian20230601').default;
    this.init_config = {
      accessKeyId:
        params?.init_config?.accessKeyId ||
        AlibabaCloudClientBaseConfig.accessKeyId,
      accessKeySecret:
        params?.init_config?.accessKeySecret ||
        AlibabaCloudClientBaseConfig.accessKeySecret,
      endpoint:
        params?.init_config?.endpoint || AlibabaCloudClientBaseConfig.endpoint,
    };
    this.params = params?.request?.args.params;
    this.body = params?.request?.args.body;
    this.method =
      params?.request?.config?.method || AlibabaCloudClientBaseConfig.method;
    this.path = params?.request?.config.path;
    this.headers = params?.request?.config.headers || {
      'Content-Type': AlibabaCloudClientBaseConfig.contentType,
    };
  }

  public init() {
    this.client = new this.sdk(this.init_config);
    return this.client;
  }

  // eslint-disable-next-line @typescript-eslint/no-empty-function
  public async sendRequest() {
    return await this.client.sendRequest(
      'POST',
      this.params,
      this.body,
      this.headers,
      this.params,
    );
  }

  public getConfig() {
    return {
      config: this.init_config,
      params: this.params,
      body: this.body,
      method: this.method,
      path: this.path,
      headers: this.headers,
    };
  }
}
